home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
me_cd25.zip
/
MUTT2.ZIP
/
BSTATS.MUT
< prev
next >
Wrap
Text File
|
1992-11-09
|
3KB
|
110 lines
;; bstats.mut : buffer stats
;; C Durland Public Domain
(include me2.h)
(include tobase.mut)
(defun
show-buffer-stats
{
(int buffer-size dot lines buffer-row wasted char-at-dot) ;; BufferInfo
(int ratio)
(buffer-stats -1 (loc buffer-size))
(ratio 0)(if (!= 0 buffer-size)(ratio (/ (* 100 dot) buffer-size)))
(msg "Row: " buffer-row "/" lines " Column: " (current-column)
" CH: 0x" (tobase char-at-dot 16)
" (" ratio "% of " buffer-size ")")
}
)
(defun
popup-buffer(int buffer-id) HIDDEN
{
(int j cw)
(j 0)(while (< j (windows))
{
(if (== buffer-id (attached-buffer j)) ;; window j is showing buffer
(done))
(+= j 1)
})
(if (== (windows) 1)(split-window))
(next-window)
(current-buffer buffer-id TRUE)
(previous-window)
})
;; Put a list of buffer into a buffer. Show various infos about those
;; buffers.
;; Format:
;; Flags buffer-size buffer-name file-name
;; Modified
;; Undo turned on
;; hidden - hard
;; hidden - soft
;; MUhH, dashes used if flag not set.
(const end-size-col 12 file-col 29)
(defun
list-buffers
{
(int buffer-size dot lines row wasted char-at-dot) ;; struct BufferInfo
(int total-bytes total-lines)
(int j num-buffers cw bp bp1 wp old-curbp)
(num-buffers (total-bytes (total-lines 0)))
(old-curbp (current-buffer))
(if (== -2 (bp (attached-buffer "*buffer-list*")))
(bp (create-buffer "*buffer-list*" BFHooHum)))
(current-buffer bp)
(clear-buffer)
(insert-text "Flags Size Buffer File")(newline)
(insert-text "----- ---- ------ ----")(newline)
(for (j 0) (< j (buffers)) (+= j 1)
{
(bp1 (nth-buffer j))
(if (!= bp bp1)
{
(buffer-stats bp1 (loc buffer-size))
; (insert-text (if (buffer-modified bp1)("*")(" ")))
(if (!= 0 (bit-and BFNoCare (buffer-flags bp1)))
(insert-text ".")
(show-flag bp1 BFModified "M"))
(show-flag bp1 BFUndo "u")
(show-flag bp1 BFHidden "H")
(show-flag bp1 BFHidden2 "h")
(to-col (- end-size-col (length-of (concat buffer-size))))
(insert-text buffer-size)
(insert-text " " (buffer-name bp1))
(to-col file-col)(insert-text (file-name bp1))
(newline)
(+= num-buffers 1)(+= total-bytes buffer-size)(+= total-lines lines)
})
})
(newline)
(to-col (- 9 (length-of (concat total-bytes))))
(insert-text total-bytes " bytes (" total-lines " lines) in "
num-buffers " buffers. ")
(beginning-of-buffer)
(buffer-modified -1 FALSE)
(current-buffer old-curbp)
(popup-buffer bp)
}
show-flag (int buffer-id flag)(string flag-on) HIDDEN
{
(insert-text
(if (!= 0 (bit-and flag (buffer-flags buffer-id))) flag-on "-"))
}
)